//
//  HMessageViewController.m
//  SSIL
//
//  Created by 余胜民 on 16/5/13.
//  Copyright © 2016年 sanmy. All rights reserved.
//

#import "HMessageViewController.h"
#import "HNoticeViewController.h"
#import "HOpinionViewController.h"
#import "HVoteViewController.h"
#import "HPushViewController.h" 

//文本
static NSString * const title = @"消息中心";
static NSString * const noticeText = @"通知公告";
static NSString * const thematicOpinionText = @"专题意见";
static NSString * const thematicVoteText = @"专题表决";
static NSString * const messagePushText = @"信息推送";

static NSString * const noticeImageName = @"message_notice";
static NSString * const opinionImageName = @"message_opinion";
static NSString * const voteImageName = @"message_vote";
static NSString * const pushImageName = @"message_push";

@interface HMessageViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) NSArray * arr;
@property (nonatomic,strong) NSArray * imageArr;

@end

@implementation HMessageViewController
- (void)viewDidLoad{
    [super viewDidLoad];
    _arr = @[noticeText,thematicOpinionText,thematicVoteText,messagePushText];
    _imageArr = @[noticeImageName,opinionImageName,voteImageName,pushImageName];
}

- (void)setupRootView {
    //设置导航
    self.title = title;
    
    
    /**************************///布局
    
    WS(ws);
    
    //设置table;
    UITableView * tableView = [[UITableView alloc] init];
    tableView.backgroundColor = [UIColor clearColor];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.bounces = NO;
    tableView.delaysContentTouches = NO;
    [self.view addSubview:tableView];
    
    /**************************///约束
    
    [tableView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(ws.view.top);
        make.left.equalTo(ws.view.left);
        make.right.equalTo(ws.view.right);
        make.bottom.equalTo(self.view.bottom);
    }];

}
#pragma mark tableView代理

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _arr.count;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * view = [[UIView alloc] init];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 59;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * const cellIdentifier = @"cellIentifier";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.textLabel.font = [UIFont baseFont];
        cell.textLabel.textColor = [UIColor baseTextColor];
        cell.detailTextLabel.textColor = [UIColor colorFromHexRGB:@"6aa6a"];
        cell.detailTextLabel.font = [UIFont baseFont];
    }
    
    [cell setMarginLineWith:tableView IndexPath:indexPath CellHeight:0 Margin:-1 IsNeedSelected:NO];
    
    cell.textLabel.text = _arr[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:_imageArr[indexPath.row]];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:
        {
            //通知公告
            HNoticeViewController *noticeController = [[HNoticeViewController alloc] init];
            [self.navigationController pushViewController:noticeController animated:YES];
        }
            break;
        case 1:
        {
            //专题意见
        }
            break;
        case 2:
        {
            //专题表决
        }
            break;
        case 3:
        {
            //信息推送
        }
            break;
            
        default:
            break;
    }

}
@end
